
soc=[0.8,0.6,0.4]
nlst=[4,3,2]

def gamestyle(last_move,mboard,current_player,current_availables):

    for ni in range(len(nlst)):
        item = nlst[ni]
        line_n_flg,player,fx,move=mboard.has_a_line(item,last_move) #fx 方向

        if line_n_flg and player==current_player:
            h = move // mboard.width
            w = move % mboard.width
            #print('has_a_line:', line_n_flg, 'player:', player, 'fx:', fx, 'move:', move, 'item:', item,'h:',h,'w:',w)
            if fx=='right':
                if w>1 and w+item<mboard.width:
                    if move-1 in current_availables and move+item in current_availables:
                        return soc[ni],fx
            if fx=='down':
                if h-1>0 and h+item<mboard.height:
                    if move - mboard.width in current_availables and move + item*mboard.width in current_availables:
                        return soc[ni],fx
            if fx=='rightdown':
                if h - 1 >=0 and w-1>=0 and h + item <mboard.height and w+item<mboard.width:
                    if move - mboard.width-1 in current_availables and  move + item*mboard.width+item in current_availables:
                        return soc[ni],fx

            if fx=='leftdown':
                if h - 1 >=0 and  w+1<mboard.width and h + item <mboard.height and w-item>=0:
                    if move - mboard.width+1 in current_availables and  move + item*mboard.width-item in current_availables:
                        return soc[ni],fx

    return 0,'nofx'





